class Solution {
public:
    bool judgeSquareSum(int c) {
        if(c==0){return true;}
        long long l=0,r=floor(sqrt(c));
        long long tmp;
        while(l<=r){
            tmp=l*l+r*r;
            if(tmp==c){return true;}
            if(tmp<c){l++;}
            if(tmp>c){r--;}
        }
        return false;
    }
};